


import APPOPTIONS from "@/app.config";
import { mobxState } from "@/data";
import routeMap from "../config/routeMap";
import LocalRoutes from "../config/localRouter";
import mergeRoutes from "./mergeRouters";





/**
 * 
 * @description 加载路由函数工具 ，如果是异步路由，
 */
const loadRouter = ({ routerList = [], loadFilterPath = [] }) => {
    if (!sessionStorage.token) {
        return;
    }

    let routes = [];
    if (APPOPTIONS.ASYNCROUTE) {

        routes = mergeRoutes(routerList, routeMap);

        mobxState.updateRoutes(routes);
    } else {
        // 如果不使用异步（后端返回）路由，则在LocalRoutes中配置填写路由表
        routes = mergeRoutes(LocalRoutes, routeMap)
        mobxState.updateRoutes(routes);
    }

}

export default loadRouter;